home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer 2.0 / Internet Surfer 2.0 (Wayzata Technology) (1996).iso / pc / textfile / faqs / motf_faq / part5 < prev   
Encoding:
Text File  |  1992-12-26  |  49.9 KB  |  1,864 lines

  1. Xref: bloom-picayune.mit.edu comp.windows.x.motif:13661 news.answers:4512
  2. Newsgroups: comp.windows.x.motif,news.answers
  3. Path: bloom-picayune.mit.edu!enterpoop.mit.edu!news.media.mit.edu!micro-heart-of-gold.mit.edu!wupost!uunet!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!news
  4. From: jan@ise.canberra.edu.au (Jan Newmarch)
  5. Subject: Motif FAQ (Part 5 of 5)
  6. Message-ID: <1992Dec10.001649.10616@csc.canberra.edu.au>
  7. Followup-To: comp.windows.x.motif
  8. Keywords: FAQ question answer
  9. Sender: news@csc.canberra.edu.au
  10. Reply-To: jan@ise.canberra.edu.au (Jan Newmarch)
  11. Organization: University of Canberra
  12. Date: Thu, 10 Dec 92 00:16:49 GMT
  13. Approved: news-answers-request@MIT.Edu
  14. Expires: +1 months
  15. Lines: 1847
  16.  
  17. Archive-name: motif-faq/part5
  18. Last-modified: Thu December 12 1992
  19. Version: 2.12
  20.  
  21.  
  22.  
  23. -----------------------------------------------------------------------------
  24. Subject: 121) TOPIC: MISCELLANEOUS
  25.  
  26. -----------------------------------------------------------------------------
  27. Subject: 122)+ What is the matter with Frame in Motif 1.2?
  28.  
  29. [Last modified: November 92]
  30.  
  31. Answer: This announcement has been made by OSF:
  32.  
  33. "IMPORTANT NOTICE
  34.  
  35. We have discovered two problems in the new 1.2 child alignment resources in
  36. XmFrame. Because some vendors may have committed, or are soon to commit to
  37. field releases of Motif 1.2 and 1.2.1, OSF's options for fixing them are
  38. limited. We are trying to deal with these in a way that does not cause
  39. hardship for application developers who will develop applications against
  40. various point versions of Motif. OSF's future actions for correction are
  41. summarized.
  42.  
  43. WHAT YOU SHOULD DO AND KNOW
  44.  
  45. 1. Mark the following change in your documentation.
  46.  
  47. On page 1-512 of the OSF/Motif Programmer's Reference, change the descriptions
  48. under XmNchildVerticalAlignment as follows (what follows is the CORRECT
  49. wording to match the current implementation):
  50.  
  51. XmALIGNMENT_WIDGET_TOP
  52.         Causes the BOTTOM edge of the title area to align
  53.         vertically with the top shadow of the Frame.
  54.  
  55. XmALIGNMENT_WIDGET_BOTTOM
  56.         Causes the TOP edge of the title area to align
  57.         vertically with the top shadow of the Frame.
  58.  
  59. 2. Note the following limitation on resource converters for Motif 1.2 and
  60. 1.2.1 implementations.
  61.  
  62. The rep types for XmFrame's XmNentryVerticalAlignment resource were
  63. incorrected implemented, which means that converters will not work properly.
  64. The following resource settings will not work from a resource file in 1.2 and
  65. 1.2.1:
  66.  
  67.         *childVerticalAlignment: alignment_baseline_bottom
  68.         *childVerticalAlignment: alignment_baseline_top
  69.         *childVerticalAlignment: alignment_widget_bottom
  70.         *childVerticalAlignment: alignment_widget_top
  71.  
  72. If you wish to set these values for these resources (note they are new
  73. constraint resources in XmFrame) you will have to set them directly in C or
  74. via uil.
  75.  
  76. WHAT WE WILL DO
  77.  
  78. The problem described in note #1 above will not be fixed in the OSF/Motif
  79. implementation until the next MAJOR release of Motif.  At that time we will
  80. correct the documentation and modify the code to match those new descriptions,
  81. but we will preserve the existing enumerated values and their behavior for
  82. backward compatibility for that release.
  83.  
  84. The fix for the problem described in note #2 will be shipped by OSF in Motif
  85. 1.2.2.
  86.  
  87. SUMMARY
  88. We are sorry for any difficulty this causes Motif users.  If you have any
  89. questions or flames (I suppose I deserve it) please send them directly to me.
  90. We sincerely hope this proactive response is better for our customers than you
  91. having to figure it out yourselves!
  92.  
  93. Libby
  94.  
  95.  
  96. -----------------------------------------------------------------------------
  97. Subject: 123)  What is IMUG and how do I join it?
  98.  
  99. Answer: IMUG is the International Motif User Group founded by Quest Windows
  100. Corporation and co-sponsored by FedUNIX.  IMUG is a non-profit organization
  101. working to keep users informed on technical and standards issues, to
  102. strengthen user groups on a local level, to increase communication among users
  103. internationally, and to promote the use of an international conference as a
  104. forum for sharing and learning more about Motif.  You can join it by
  105.  
  106.  1.  Pay the annual membership fee of $20 USD directly to IMUG.  Contact
  107.  
  108.      IMUG
  109.      5200 Great America Parkway
  110.      Santa Clara,  CA  95054
  111.      (408) 496-1900
  112.      imug@quest.com
  113.  
  114.  2.  Register at the International Motif User Conference, and automatically
  115.      become an IMUG member.
  116.  
  117.  3.  Donate a pd widget, widget tool or widget builder to the IMUG Widget
  118.      Depository and receive a free one year IMUG membership.
  119.  
  120.  
  121.  
  122. -----------------------------------------------------------------------------
  123. Subject: 124)  How do I set the title of a top level window?
  124. [Last modified: September 92]
  125.  
  126. Answer: Set XmNtitle (and optionally XmNtitleEncoding) for TopLevelShells.
  127. (Note that this is of type String rather than XmStrin.) Ypu can also set
  128. XmNiconName if you want its icon to show this title.  For XmDialogShells, set
  129. the XmNdialogTitle of its immediate child, assuming it's a BulletinBoard
  130. subclass.  These can also be set in resource files.
  131.  
  132.  
  133. -----------------------------------------------------------------------------
  134. Subject: 125)  Can I use editres with Motif?
  135. [Last modified: August 92]
  136.  
  137. Answer: It isn't built in to Motif (at 1.2.0), but you can do this in your
  138. application
  139.  
  140.     extern void _XEditResCheckMessages();
  141.     ...
  142.     XtAddEventHandler(shell_widget, (EventMask)0, True,
  143.                         _XEditResCheckMessages, NULL);
  144.  
  145. once for each shell widget that you want to react to the "click to select
  146. client" protocol.  Then link your client with the R5 libXmu.
  147.  
  148. David Brooks, OSF
  149.  
  150.  
  151. -----------------------------------------------------------------------------
  152. Subject: 126)  How can I put decorations on transient windows using olwm?
  153.  
  154. Answer: From Jean-Philippe Martin-Flatin <syj@ecmwf.co.uk>
  155.  
  156. /**********************************************************************
  157. ** WindowDecorations.c
  158. **
  159. ** Manages window decorations under the OpenLook window manager (OLWM).
  160. **
  161. ** Adapted from a C++ program posted to comp.windows.x.motif by:
  162. **
  163. **    +--------------------------------------------------------------+
  164. **    | Ron Edmark                          User Interface Group     |
  165. **    | Tel:        (408) 980-1500 x282     Integrated Systems, Inc. |
  166. **    | Internet:   edmark@isi.com          3260 Jay St.             |
  167. **    | Voice mail: (408) 980-1590 x282     Santa Clara, CA 95054    |
  168. **    +--------------------------------------------------------------+
  169. ***********************************************************************/
  170.  
  171. #include <X11/X.h>
  172. #include <X11/Xlib.h>
  173. #include <X11/Xatom.h>
  174. #include <X11/Intrinsic.h>
  175. #include <X11/StringDefs.h>
  176. #include <X11/Protocols.h>
  177. #include <Xm/Xm.h>
  178. #include <Xm/AtomMgr.h>
  179.  
  180. /*
  181. ** Decorations for OpenLook:
  182. ** The caller can OR different mask options to change the frame decoration.
  183. */
  184. #define OLWM_Header     (long)(1<<0)
  185. #define OLWM_Resize     (long)(1<<1)
  186. #define OLWM_Close      (long)(1<<2)
  187.  
  188. /*
  189. ** Prototypes
  190. */
  191. static void InstallOLWMAtoms  (Widget w);
  192. static void AddOLWMDialogFrame(Widget widget, long decorationMask);
  193.  
  194.  
  195. /*
  196. ** Global variables
  197. */
  198. static Atom AtomWinAttr;
  199. static Atom AtomWTOther;
  200. static Atom AtomDecor;
  201. static Atom AtomResize;
  202. static Atom AtomHeader;
  203. static Atom AtomClose;
  204. static int  not_installed_yet = TRUE;
  205.  
  206.  
  207. static void InstallOLWMAtoms(Widget w)
  208. {
  209.         AtomWinAttr = XInternAtom(XtDisplay(w), "_OL_WIN_ATTR" ,    FALSE);
  210.         AtomWTOther = XInternAtom(XtDisplay(w), "_OL_WT_OTHER",     FALSE);
  211.         AtomDecor   = XInternAtom(XtDisplay(w), "_OL_DECOR_ADD",    FALSE);
  212.         AtomResize  = XInternAtom(XtDisplay(w), "_OL_DECOR_RESIZE", FALSE);
  213.         AtomHeader  = XInternAtom(XtDisplay(w), "_OL_DECOR_HEADER", FALSE);
  214.         AtomClose   = XInternAtom(XtDisplay(w), "_OL_DECOR_CLOSE",  FALSE);
  215.  
  216.         not_installed_yet = FALSE;
  217. }
  218.  
  219. static void AddOLWMDialogFrame(Widget widget, long decorationMask)
  220. {
  221.         Atom   winAttrs[2];
  222.         Atom   winDecor[3];
  223.         Widget shell = widget;
  224.         Window win;
  225.         int    numberOfDecorations = 0;
  226.  
  227.         /*
  228.         ** Make sure atoms for OpenLook are installed only once
  229.         */
  230.         if (not_installed_yet) InstallOLWMAtoms(widget);
  231.  
  232.         while (!XtIsShell(shell)) shell = XtParent(shell);
  233.  
  234.         win = XtWindow(shell);
  235.  
  236.         /*
  237.         ** Tell Open Look that our window is not one of the standard OLWM window        ** types. See OLIT Widget Set Programmer's Guide pp.70-73.
  238.         */
  239.  
  240.         winAttrs[0] = AtomWTOther;
  241.  
  242.         XChangeProperty(XtDisplay(shell),
  243.                         win,
  244.                         AtomWinAttr,
  245.                         XA_ATOM,
  246.                         32,
  247.                         PropModeReplace,
  248.                         (unsigned char*)winAttrs,
  249.                         1);
  250.  
  251.         /*
  252.         ** Tell Open Look to add some decorations to our window
  253.         */
  254.         numberOfDecorations = 0;
  255.         if (decorationMask & OLWM_Header)
  256.                 winDecor[numberOfDecorations++] = AtomHeader;
  257.         if (decorationMask & OLWM_Resize)
  258.                 winDecor[numberOfDecorations++] = AtomResize;
  259.         if (decorationMask & OLWM_Close)
  260.         {
  261.                 winDecor[numberOfDecorations++] = AtomClose;
  262.  
  263.                 /*
  264.                 ** If the close button is specified, the header must be
  265.                 ** specified. If the header bit is not set, set it.
  266.                 */
  267.                 if (!(decorationMask & OLWM_Header))
  268.                         winDecor[numberOfDecorations++] = AtomHeader;
  269.         }
  270.  
  271.         XChangeProperty(XtDisplay(shell),
  272.                         win,
  273.                         AtomDecor,
  274.                         XA_ATOM,
  275.                         32,
  276.                         PropModeReplace,
  277.                         (unsigned char*)winDecor,
  278.                         numberOfDecorations);
  279. }
  280.  
  281.  
  282. /*
  283. ** Example of use of AddOLWMDialogFrame, with a bit of extra stuff
  284. */
  285. void register_dialog_to_WM(Widget shell, XtCallbackProc Cbk_func)
  286. {
  287.         Atom atom;
  288.  
  289.         /*
  290.         ** Alias the "Close" item in system menu attached to dialog shell
  291.         ** to the activate callback of "Exit" in the menubar
  292.         */
  293.         if (Cbk_func)
  294.         {
  295.             atom = XmInternAtom(XtDisplay(shell),"WM_DELETE_WINDOW",TRUE);
  296.             XmAddWMProtocolCallback(shell,atom, Cbk_func,NULL);
  297.         }
  298.  
  299.         /*
  300.         ** If Motif is the window manager, skip OpenLook specific stuff
  301.         */
  302.         if (XmIsMotifWMRunning(shell)) return;
  303.  
  304.         /*
  305.         ** Register dialog shell to OpenLook.
  306.         **
  307.         ** WARNING: on some systems, adding the "Close" button allows the title
  308.         ** to be properly centered in the title bar. On others, activating
  309.         ** "Close" crashes OpenLook. The reason is not clear yet, but it seems
  310.         ** the first case occurs with OpenWindows 2 while the second occurs with
  311.         ** Openwindows 3. Thus, comment out one of the two following lines as
  312.         ** suitable for your site, and send e-mail to syj@ecmwf.co.uk if you
  313.         ** find out what is going on !
  314.         */
  315.         AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize));
  316. /*      AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize | OLWM_Close)); */
  317. }
  318.  
  319.  
  320. -----------------------------------------------------------------------------
  321. Subject: 127) Why does an augment translation appear to act as replace for
  322. some widgets?  When I use either augment or override translations in
  323. .Xdefaults it seems to act as replace in both Motif 1.0 and 1.1
  324.  
  325. Answer: By default, the translation table is NULL.  If there is nothing
  326. specified (either in resource file, or in args), the widget's Initialize
  327. finds: Oh, there is NULL in translations, lets use our default ones.  If,
  328. however, the translations have become non-NULL, the default translations are
  329. NOT used at all. Thus, using #augment, #override or a new table has identical
  330. effect: defines the new translations. The only way you can augment/override
  331. Motif's default translations is AFTER Initialize, using XtSetValues.  Note,
  332. however, that Motif managers do play with translation tables as well ... so
  333. that results are not always easy to predict.
  334.  
  335. From OSF: A number of people have complained about not being able to
  336. augment/override translations from the .Xdefaults.  This is due to the
  337. complexity of the menu system/keyboard traversal and the necessary
  338. translations changes required to support the Motif Style Guide in menus.  It
  339. cannot be fixed in a simple way. Fixing it requires re-design of the
  340. menus/buttons and it is planned to be fixed in 1.2.
  341.  
  342.  
  343.  
  344.  
  345.  
  346. -----------------------------------------------------------------------------
  347. Subject: 128) How do you "grey" out a widget so that it cannot be activated?
  348.  
  349. Answer: Use XtSetSensitive(widget, False). Do not set the XmNsensitive
  350. resource directly yourself (by XtSetValues) since the widget may need to talk
  351. to parents first.
  352.  
  353.  
  354. -----------------------------------------------------------------------------
  355. Subject: 129) Why doesn't the Help callback work on some widgets?
  356.  
  357. Answer: If you press the help key the help callback of the widget with the
  358. keyboard focus is called (not the one containing the mouse).  You can't get
  359. the help callback of a non-keyboard-selectable widget called. To get `context
  360. sensitive' help on these, you have to find the mouse, associate its position
  361. with a widget and then do the help.
  362.  
  363.  
  364.  
  365. -----------------------------------------------------------------------------
  366. Subject: 130) Where can I get a Table widget?
  367.  
  368. Answer: Send email to Kee Hinckley (nazgul@alfalfa.com) asking for a copy of
  369. his table widget.  The Widget Creation Library also has one.  See under Motif
  370. prototyping tools for the contact.
  371.  
  372. Expert Database Systems, Inc., 305 Madison Ave, Suite 1166, New York, NY 10165
  373. has a very comprehensive table widget that uses both motif scrollbars or a
  374. "virtual" scrollbar showing a miniature version of the entire spreadsheet.
  375. Allows for different width columns, changing colors in each cell.  Only one
  376. X-Window is used so as to reduce the amount of system resources used.  Contact
  377. Ken Jones
  378.  
  379.  
  380. -----------------------------------------------------------------------------
  381. Subject: 131)  Has anyone done a bar graph widget?
  382. [Last modified: September 92]
  383.  
  384. Answer: You can fake one by using for each bar a scroll bar or even a label
  385. which changes in size, put inside a container of some kind.
  386.  
  387. Try the StripChart widget in the Athena widget set. Set the XtNupdate resource
  388. to 0 to keep it from automatically updating.
  389.  
  390. The comp.windows.x FAQ mentions a bar graph widget.
  391.  
  392. Expert Database Systems, Inc.  sells a bar graph widget as well as a multi-
  393. line graph with automatic scaling, a 3-D surface graph, and a high/Low graph
  394. with two lines for moving averages.  Contact Ken Jones Expert Database
  395. Systems, Inc., 305 Madison Ave, Suite 1166, New York, NY 10165, Main Number:
  396. (212) 370-6700, Phone Mail:  (212) 714-8345
  397.  
  398. The Xtra XWidget library contains a set of widgets that are subclassed from
  399. and compatible with either OSF/Motif or OLIT widgets.  The library includes
  400. widgets that implement the following:
  401.  
  402.    Spreadsheet
  403.    Bar Graph
  404.    Stacked Bar Graph
  405.    Line Graph
  406.    Pie Chart
  407.    XY Plot
  408.    Hypertext
  409.    Hypertext based Help System
  410.    Entry Form with type checking
  411.  
  412. Contact Graphical Software Technology at 310-328-9338  (info@gst.com) for
  413. information.
  414.  
  415. The XRT/graph widget, available for Motif, XView and OLIT, displays X-Y plots,
  416. bar and pie charts, and supports user-feedback, fast updates and PostScript
  417. output. Contact KL Group Inc. at 416-594-1026 (xrt_info%klg@uunet.ca)
  418.  
  419. The product Xmath, made by Integrated Systems Inc. is a product which has
  420. interactive 2d and 3d graphics for bar,strip,line,symbol,
  421. surface,contour,etc... that costs $2500.00 for commercial use and a mere
  422. $250.00 for university use that also has complete numerics capabilities, an
  423. easy to use debugger, a complete high level language, a spreadsheet, a motif
  424. gui access capability, and much more all created on top of motif.
  425.  
  426. You can either email to xmath-info@isi.com or call (408)980-1500.
  427.  
  428. Digital Equipment Corporation (DEC) provides the following product NetEd: "The
  429. network editor widget is a Motif toolkit conforming widget that applications
  430. can use to express complex interrelationships graphically in the form of
  431. networks or graphs. The network editor supports interactive or application-
  432. controlled creation and editing of directed graphs or networks."
  433.  
  434.  
  435. ACE/gr is an X based XY plotting tool implemented with a point 'n click
  436. paradigm.  A few of its features are:
  437.  
  438.    * Plots up to 10 graphs with 30 data sets per graph.
  439.    * Data read from files and/or pipes.
  440.    * Graph types XY, log-linear, linear-log, log-log, bar,
  441.         stacked bar charts.
  442.  
  443. it is available from
  444.  
  445.         ftp.ccalmr.ogi.edu (presently amb4.ccalmr.ogi.edu)
  446.  
  447. with IP address 129.95.72.34. The XView version (xvgr) will be found in
  448. /CCALMR/pub/acegr/xvgr-2.09.tar.Z and the Motif version (xmgr) in
  449. /CCALMR/pub/acegr/xmgr-2.09.tar.Z.  Comments, suggestions, bug reports to
  450. pturner@amb4.ccalmr.ogi.edu (if mail fails, try pturner@ese.ogi.edu). Due to
  451. time constraints, replies will be few and far between.
  452.  
  453.  
  454.  
  455. -----------------------------------------------------------------------------
  456. Subject: 132)  Does anyone know of a source code of a graph widget where you
  457. can add vertices and edges and get an automated updating?
  458.  
  459. [Last modified: September 92]
  460.  
  461. Answer: The XUG FAQ in comp.windows.x includes information on graph display
  462. widgets.  There is also an implementation in the Asente/Swick book.
  463.  
  464.   From Martin Janzen: "You could have a look at DataViews, from V.I.
  465.    Corporation.  This package is used mainly to display a variety of graph
  466.    drawings (eg. bar, line, pie, high/low, and other charts), and to update
  467.    the graphs as information is received from "data sources" such as files,
  468.    processes (through pipes), or devices.
  469.  
  470.    However, it also provides "node" and "edge" objects which can be used
  471.    when working with network graphs.  The DV-Tools function library
  472.    provides routines which traverse a graph, count visits to each node or
  473.    edge, mark nodes or edges of interest, and so on.  A node or edge object
  474.    can have an associated "geometry object" (such as a symbol or a line),
  475.    which represents that node or edge.
  476.  
  477.    Drawbacks: There's no automatic positioning algorithm; when you add a
  478.    node or edge, you have to create and position its geometry object
  479.    yourself.  Also, this isn't a set of add-on widgets; you can either have
  480.    DataViews create an X window (ie. a separate shell), or you can create
  481.    your own XmDrawingArea and use DataViews to update its window when
  482.    expose events are received.  Finally, the package is quite expensive,
  483.    and there is a run-time charge.
  484.  
  485.    The vendor's address is:
  486.      V.I. Corporation,
  487.      47 Pleasant Street,
  488.      Northampton, MA  01060,
  489.             Email: vi@vicorp.com, Phone: (413) 586-4144, Fax:   (413) 584-2649
  490.  
  491.    or
  492.  
  493.      V.I. Corporation (Europe) Ltd.,
  494.      First Base, Beacontree Plaza,
  495.      Gillette Way,                      Email: viesales@eurovi.uucp
  496.      Reading, Berkshire  RG2 0BP"
  497.    Phone: +44 734 756010,      Fax:   +44 734 756104
  498.  
  499. From Craig Timmerman: Just wanted others to know that there is a third
  500. competitor in what may be come a big market for generic APIs.  The product is
  501. called Open Interface and Neuron Data is the vendor.  Neuron has added some
  502. extra, more complex widgets to their set.  The two most notable are a table
  503. and network widget.  [...] I believe that the network widget got its name from
  504. its ability to display expert system networks that Neuron's AI tools needed.
  505. It would be more aptly named the graph widget.  It can display and manipulate
  506. graphs of various types (trees, directed graphs, etc).  Contact is
  507.  
  508.         Neuron Data
  509.         156 University Avenue
  510.         Palo Alto,  CA  94301
  511.         (415) 321-4488
  512.  
  513.  
  514. prism!gt3273b@gatech.edu  (RENALDS,ANDREW THEODORE) posted a set of public
  515. domain routines for graph drawing.  Contact him for a later set.
  516.  
  517. From Ramon Santiago (santiago@fgssu1.fgs.slb.com): HP has released source code
  518. for XmGraph and XmArc, part of the InterWorks library, which does exactly
  519. this. The sources can be obtained by contacting Dave Shaw,
  520. librarian@iworks.ecn.uiowa.edu. A few trivial source code changes need to be
  521. made to get these widgets to compile under Motif 1.2.
  522.  
  523.  
  524. -----------------------------------------------------------------------------
  525. Subject: 133)  Is there a help system available, such as in Windows 3?  Or any
  526. Motif based hypertext system.
  527.  
  528. Answer:
  529.  
  530. Bristol Technology have a hypertext system HyperHelp with the look-and-feel of
  531. either Motif or OpenLook. It should be available from january 31, 1992.
  532. Contact
  533.  
  534.         Bristol Technology Inc.
  535.         898 Ethan Allen Highway
  536.         Ridgefield, CT  06877
  537.         203-438-6969 (phone)
  538.         203-438-5013 (fax)
  539.         uunet.uu.net!bristol!keith
  540.  
  541. Demos are available by anonymous ftp from  ftp.uu.net (137.39.1.9) in the
  542. vendor/Bristol/HyperHelp as files sun.motif.tar.Z and hp.tar.Z.
  543.  
  544. There was a posting of a motif hypertext-widget to comp.sources.x (Author:
  545. B.Raoult ( mab@ecmwf.co.uk ) ).  It had the facility to read in helptext from
  546. a file.
  547.  
  548. From Francois Felix Ingrand (felix@idefix.laas.fr): I have translated the Info
  549. AW (originally written by Jordan Hubbard) to Motif. It is a Widget to browse
  550. Info files (format used by GNU for their various documentations). I use it as
  551. the help system of various tool I wrote.  It is available on laas.laas.fr
  552. (140.93.0.15) in /pub/prs/xinfo-motif.tar.Z
  553.  
  554. Form Scott Raney (raney@metacard.com) MetaCard is a commercial package that
  555. can be used to implement hypertext help.  The text fields support multiple
  556. typefaces, sizes, styles, colors, subscript/superscript, and hypertext links.
  557. It has a Motif interface, and a template for calling it from an Xt/Motif
  558. application is included.  You can FTP a save-disabled distribution from
  559. ftp.metacard.com or from world.std.com.  For more info, email to
  560. info@metacard.com.
  561.  
  562.  
  563.  
  564.  
  565. -----------------------------------------------------------------------------
  566. Subject: 134) Can I specify a widget in a resource file?
  567.  
  568. Answer: This answer, which uses the Xmu library, is due to David Elliott.  If
  569. the converter is added, then the name of a widget (a string) can be used in
  570. resource files, and will be converted to the appropriate widget.
  571.  
  572. This code, which was basically stolen from the Athena Form widget, adds a
  573. String to Widget converter.  I wrote it as a general routine that I call at
  574. the beginning of all of my programs, and made it so I could add other
  575. converters as needed (like String to Unit Type ;-).
  576.  
  577.         #include <X11/Intrinsic.h>
  578.         #include <X11/StringDefs.h>
  579.         #include <Xm/Xm.h>
  580.         #include <X11/Xmu/Converters.h>
  581.         #include <X11/IntrinsicP.h>
  582.         #include <X11/CoreP.h>
  583.  
  584.         void
  585.         setupConverters()
  586.         {
  587.                 static XtConvertArgRec parentCvtArgs[] = {
  588.                         {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent),
  589.                                 sizeof(Widget)}
  590.                 };
  591.  
  592.                 XtAddConverter(XmRString, XmRWindow, XmuCvtStringToWidget,
  593.                         parentCvtArgs, XtNumber(parentCvtArgs));
  594.         }
  595.  
  596.  
  597.  
  598. -----------------------------------------------------------------------------
  599. Subject: 135) Why are only some of my translations are being installed?  I
  600. have a translation table like the following, but only the first ones are
  601. getting installed and the rest are ignored.
  602.  
  603.  *Text.translations:    #override \
  604.      Ctrl<Key>a:    beginning-of-line() \n\
  605.      Ctrl<Key>e:    end-of-line() \n\
  606.      Ctrl<Key>f:    forward-character() \n\
  607.  
  608.  
  609. Answer: Most likely, you have a space at the end of one of the lines (the
  610. first in this case).
  611.  
  612.      Ctrl<Key>a:    beginning-of-line() \n\
  613.                                            ^ space here
  614.  
  615. The second backslash in each line is there to protect the real newline
  616. character and so you must not follow it with anything other than the newline
  617. itself. Otherwise it acts as the end of the resource definition and the
  618. remaining lines are not added.
  619.  
  620.  
  621. -----------------------------------------------------------------------------
  622. Subject: 136)  Where can I get the PanHandler code?
  623.  
  624. Answer: It is available by email from Chuck Ocheret:  chuck@IMSI.COM.
  625.  
  626. -----------------------------------------------------------------------------
  627. Subject: 137) What are these passive grab warnings?  When I destroy certain
  628. widgets I get a stream of messages
  629.  
  630.     Warning: Attempt to remove non-existant passive grab
  631.  
  632.  
  633. Answer: They are meaningless, and you want to ignore them.  Do this (from Kee
  634. Hinckley) by installing an XtWarning handler that explicitly looks for them
  635. and discards them:
  636.  
  637.         static void xtWarnCB(String message) {
  638.            if (asi_strstr(message, "non-existant passive grab", TRUE)) return;
  639.            ...
  640.  
  641. They come from Xt, and (W. Scott Meeks): "it's something that the designers of
  642. Xt decided the toolkit should do. Unfortunately, Motif winds up putting
  643. passive grabs all over the place for the menu system.  On the one hand, we
  644. want to remove all these grabs when menus get destroyed so that they don't
  645. leak memory; on the other hand, it's almost impossible to keep track of all
  646. the grabs, so we have a conservative strategy of ungrabbing any place where a
  647. grab could have been made and we don't explicitly know that there is no grab.
  648. The unfortunate side effect is the little passive grab warning messages.
  649. We're trying to clean these up where possible, but there are some new places
  650. where the warning is generated.  Until we get this completely cleaned up (1.2
  651. maybe), your best bet is probably to use a warning handler."
  652.  
  653. -----------------------------------------------------------------------------
  654. Subject: 138) How do I have more buttons than three in a box?  I want to have
  655. something like a MessageBox (or other widget) with more than three buttons,
  656. but with the same nice appearance.
  657.  
  658. Answer: A SelectionBox is created with four buttons, but the fourth (the Apply
  659. button) is unmanaged. To manage it get its widget ID via
  660. XmSelectionBoxGetChild(parent, XmDIALOG_APPLY_BUTTON) and then XtManage it.
  661. Unmanage all of the other bits in the SelectionBox that you don't want.  If
  662. you want more than four buttons, try two SelectionBoxes (or similar) together
  663. in a container, where all of the unwanted parts of the widgets are unmanaged.
  664.  
  665. Alternatively, build your own dialog:
  666.  
  667. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  668.  * This program is freely distributable without licensing fees and
  669.  * is provided without guarantee or warranty expressed or implied.
  670.  * This program is -not- in the public domain.  This program is
  671.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  672.  */
  673.  
  674. /* action_area.c -- demonstrate how CreateActionArea() can be used
  675.  * in a real application.  Create what would otherwise be identified
  676.  * as a PromptDialog, only this is of our own creation.  As such,
  677.  * we provide a TextField widget for input.  When the user presses
  678.  * Return, the Ok button is activated.
  679.  */
  680. #include <Xm/DialogS.h>
  681. #include <Xm/PushBG.h>
  682. #include <Xm/PushB.h>
  683. #include <Xm/LabelG.h>
  684. #include <Xm/PanedW.h>
  685. #include <Xm/Form.h>
  686. #include <Xm/RowColumn.h>
  687. #include <Xm/TextF.h>
  688.  
  689. typedef struct {
  690.     char *label;
  691.     void (*callback)();
  692.     caddr_t data;
  693. } ActionAreaItem;
  694.  
  695. static void
  696.     do_dialog(), close_dialog(), activate_cb(),
  697.     ok_pushed(), cancel_pushed(), help();
  698.  
  699. main(argc, argv)
  700. int argc;
  701. char *argv[];
  702. {
  703.     Widget toplevel, button;
  704.     XtAppContext app;
  705.  
  706.     toplevel = XtVaAppInitialize(&app, "Demos",
  707.         NULL, 0, &argc, argv, NULL, NULL);
  708.  
  709.     button = XtVaCreateManagedWidget("Push Me",
  710.         xmPushButtonWidgetClass, toplevel, NULL);
  711.     XtAddCallback(button, XmNactivateCallback, do_dialog, NULL);
  712.  
  713.     XtRealizeWidget(toplevel);
  714.     XtAppMainLoop(app);
  715. }
  716.  
  717. /* callback routine for "Push Me" button.  Actually, this represents
  718.  * a function that could be invoked by any arbitrary callback.  Here,
  719.  * we demonstrate how one can build a standard customized dialog box.
  720.  * The control area is created here and the action area is created in
  721.  * a separate, generic routine: CreateActionArea().
  722.  */
  723. static void
  724. do_dialog(w, file)
  725. Widget w; /* will act as dialog's parent */
  726. char *file;
  727. {
  728.     Widget dialog, pane, rc, label, text_w, action_a;
  729.     XmString string;
  730.     extern Widget CreateActionArea();
  731.     Arg args[10];
  732.     static ActionAreaItem action_items[] = {
  733.         { "Ok",     ok_pushed,     NULL          },
  734.         { "Cancel", cancel_pushed, NULL          },
  735.         { "Close",  close_dialog,  NULL          },
  736.         { "Help",   help,          "Help Button" },
  737.     };
  738.  
  739.     /* The DialogShell is the Shell for this dialog.  Set it up so
  740.      * that the "Close" button in the window manager's system menu
  741.      * destroys the shell (it only unmaps it by default).
  742.      */
  743.     dialog = XtVaCreatePopupShell("dialog",
  744.         xmDialogShellWidgetClass, XtParent(w),
  745.         XmNtitle,  "Dialog Shell",     /* give arbitrary title in wm */
  746.         XmNdeleteResponse, XmDESTROY,  /* system menu "Close" action */
  747.         NULL);
  748.  
  749.     /* now that the dialog is created, set the Close button's
  750.      * client data, so close_dialog() will know what to destroy.
  751.      */
  752.     action_items[2].data = (caddr_t)dialog;
  753.  
  754.     /* Create the paned window as a child of the dialog.  This will
  755.      * contain the control area (a Form widget) and the action area
  756.      * (created by CreateActionArea() using the action_items above).
  757.      */
  758.     pane = XtVaCreateWidget("pane", xmPanedWindowWidgetClass, dialog,
  759.         XmNsashWidth,  1,
  760.         XmNsashHeight, 1,
  761.         NULL);
  762.  
  763.     /* create the control area (Form) which contains a
  764.      * Label gadget and a List widget.
  765.      */
  766.     rc = XtVaCreateWidget("control_area", xmRowColumnWidgetClass, pane, NULL);
  767.     string = XmStringCreateSimple("Type Something:");
  768.     XtVaCreateManagedWidget("label", xmLabelGadgetClass, rc,
  769.         XmNlabelString,    string,
  770.         XmNleftAttachment, XmATTACH_FORM,
  771.         XmNtopAttachment,  XmATTACH_FORM,
  772.         NULL);
  773.     XmStringFree(string);
  774.  
  775.     text_w = XtVaCreateManagedWidget("text-field",
  776.         xmTextFieldWidgetClass, rc, NULL);
  777.  
  778.     /* RowColumn is full -- now manage */
  779.     XtManageChild(rc);
  780.  
  781.     /* Set the client data "Ok" and "Cancel" button's callbacks. */
  782.     action_items[0].data = (caddr_t)text_w;
  783.     action_items[1].data = (caddr_t)text_w;
  784.  
  785.     /* Create the action area -- we don't need the widget it returns. */
  786.     action_a = CreateActionArea(pane, action_items, XtNumber(action_items));
  787.  
  788.     /* callback for Return in TextField.  Use action_a as client data */
  789.     XtAddCallback(text_w, XmNactivateCallback, activate_cb, action_a);
  790.  
  791.     XtManageChild(pane);
  792.     XtPopup(dialog, XtGrabNone);
  793. }
  794.  
  795. /*--------------*/
  796. /* The next four functions are the callback routines for the buttons
  797.  * in the action area for the dialog created above.  Again, they are
  798.  * simple examples, yet they demonstrate the fundamental design approach.
  799.  */
  800. static void
  801. close_dialog(w, shell)
  802. Widget w, shell;
  803. {
  804.     XtDestroyWidget(shell);
  805. }
  806.  
  807. /* The "ok" button was pushed or the user pressed Return */
  808. static void
  809. ok_pushed(w, text_w, cbs)
  810. Widget w, text_w;         /* the text widget is the client data */
  811. XmAnyCallbackStruct *cbs;
  812. {
  813.     char *text = XmTextFieldGetString(text_w);
  814.  
  815.     printf("String = %s0, text);
  816.     XtFree(text);
  817. }
  818.  
  819. static void
  820. cancel_pushed(w, text_w, cbs)
  821. Widget w, text_w;         /* the text field is the client data */
  822. XmAnyCallbackStruct *cbs;
  823. {
  824.     /* cancel the whole operation; reset to NULL. */
  825.     XmTextFieldSetString(text_w, "");
  826. }
  827.  
  828. static void
  829. help(w, string)
  830. Widget w;
  831. String string;
  832. {
  833.     puts(string);
  834. }
  835. /*--------------*/
  836.  
  837. /* When Return is pressed in TextField widget, respond by getting
  838.  * the designated "default button" in the action area and activate
  839.  * it as if the user had selected it.
  840.  */
  841. static void
  842. activate_cb(text_w, client_data, cbs)
  843. Widget text_w;              /* user pressed Return in this widget */
  844. XtPointer client_data;        /* action_area passed as client data */
  845. XmAnyCallbackStruct *cbs;   /* borrow the "event" field from this */
  846. {
  847.     Widget dflt, action_area = (Widget)client_data;
  848.  
  849.     XtVaGetValues(action_area, XmNdefaultButton, &dflt, NULL);
  850.     if (dflt) /* sanity check -- this better work */
  851.         /* make the default button think it got pushed.  This causes
  852.          * "ok_pushed" to be called, but XtCallActionProc() causes
  853.          * the button appear to be activated as if the user selected it.
  854.          */
  855.         XtCallActionProc(dflt, "ArmAndActivate", cbs->event, NULL, 0);
  856. }
  857.  
  858. #define TIGHTNESS 20
  859.  
  860. Widget
  861. CreateActionArea(parent, actions, num_actions)
  862. Widget parent;
  863. ActionAreaItem *actions;
  864. int num_actions;
  865. {
  866.     Widget action_area, widget;
  867.     int i;
  868.  
  869.     action_area = XtVaCreateWidget("action_area", xmFormWidgetClass, parent,
  870.         XmNfractionBase, TIGHTNESS*num_actions - 1,
  871.         XmNleftOffset,   10,
  872.         XmNrightOffset,  10,
  873.         NULL);
  874.  
  875.     for (i = 0; i < num_actions; i++) {
  876.         widget = XtVaCreateManagedWidget(actions[i].label,
  877.             xmPushButtonWidgetClass, action_area,
  878.             XmNleftAttachment,       i? XmATTACH_POSITION : XmATTACH_FORM,
  879.             XmNleftPosition,         TIGHTNESS*i,
  880.             XmNtopAttachment,        XmATTACH_FORM,
  881.             XmNbottomAttachment,     XmATTACH_FORM,
  882.             XmNrightAttachment,
  883.                     i != num_actions-1? XmATTACH_POSITION : XmATTACH_FORM,
  884.             XmNrightPosition,        TIGHTNESS*i + (TIGHTNESS-1),
  885.             XmNshowAsDefault,        i == 0,
  886.             XmNdefaultButtonShadowThickness, 1,
  887.             NULL);
  888.         if (actions[i].callback)
  889.             XtAddCallback(widget, XmNactivateCallback,
  890.                 actions[i].callback, actions[i].data);
  891.         if (i == 0) {
  892.             /* Set the action_area's default button to the first widget
  893.              * created (or, make the index a parameter to the function
  894.              * or have it be part of the data structure). Also, set the
  895.              * pane window constraint for max and min heights so this
  896.              * particular pane in the PanedWindow is not resizable.
  897.              */
  898.             Dimension height, h;
  899.             XtVaGetValues(action_area, XmNmarginHeight, &h, NULL);
  900.             XtVaGetValues(widget, XmNheight, &height, NULL);
  901.             height += 2 * h;
  902.             XtVaSetValues(action_area,
  903.                 XmNdefaultButton, widget,
  904.                 XmNpaneMaximum,   height,
  905.                 XmNpaneMinimum,   height,
  906.                 NULL);
  907.         }
  908.     }
  909.  
  910.     XtManageChild(action_area);
  911.  
  912.     return action_area;
  913. }
  914.  
  915.  
  916.  
  917. -----------------------------------------------------------------------------
  918. Subject: 139)  How do I create a "busy working cursor"?
  919.  
  920. Answer: - in Baudouin's code (following), the idea is to keep in an array an
  921. up-to-date list of all shells used in the application, and set for all of them
  922. the cursor to a watch or to the default cursor, with the 2 functions provided.
  923.  
  924. - in Dan Heller's code (later), the idea is to turn on the watch cursor for
  925. the top-level shell only, popup a working window to possibly abort the
  926. callback, and manage some expose events during the callback.
  927.  
  928. - in the FAQ for comp.windows.x (#113), the idea is to bring a large window on
  929. top of the application, hide all windows below it, and turn on the watch
  930. cursor on this large window. Unmapping the large window resets the default
  931. cursor, mapping it turns on the watch cursor.
  932.  
  933. From Baudouin Raoult (mab@ecmwf.co.uk)
  934.  
  935. void my_SetWatchCursor(w)
  936. Widget w;
  937. {
  938.         static Cursor watch = NULL;
  939.  
  940.         if(!watch)
  941.                 watch = XCreateFontCursor(XtDisplay(w),XC_watch);
  942.  
  943.         XDefineCursor(XtDisplay(w),XtWindow(w),watch);
  944.         XmUpdateDisplay(w);
  945. }
  946.  
  947. void my_ResetCursor(w)
  948. Widget w;
  949. {
  950.         XUndefineCursor(XtDisplay(w),XtWindow(w));
  951.         XmUpdateDisplay(w);
  952. }
  953.  
  954.  
  955. Answer: A solution with lots of bells and whistles is
  956.  
  957. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  958.  * This program is freely distributable without licensing fees and
  959.  * is provided without guarantee or warrantee expressed or implied.
  960.  * This program is -not- in the public domain.
  961.  */
  962.  
  963. /* busy.c -- demonstrate how to use a WorkingDialog and to process
  964.  * only "important" events.  e.g., those that may interrupt the
  965.  * task or to repaint widgets for exposure.  Set up a simple shell
  966.  * and a widget that, when pressed, immediately goes into its own
  967.  * loop.  First, "lock" the shell so that a timeout cursor is set on
  968.  * the shell and pop up a WorkingDialog.  Then enter loop ... sleep
  969.  * for one second ten times, checking between each interval to see
  970.  * if the user clicked the Stop button or if any widgets need to be
  971.  * refreshed.  Ignore all other events.
  972.  *
  973.  * main() and get_busy() are stubs that would be replaced by a real
  974.  * application; all other functions can be used "as is."
  975.  */
  976. #include <Xm/MessageB.h>
  977. #include <Xm/PushB.h>
  978. #include <X11/cursorfont.h>
  979.  
  980. Widget shell;
  981. void TimeoutCursors();
  982. Boolean CheckForInterrupt();
  983.  
  984. main(argc, argv)
  985. int argc;
  986. char *argv[];
  987. {
  988.     XtAppContext app;
  989.     Widget button;
  990.     XmString label;
  991.     void get_busy();
  992.  
  993.     shell = XtVaAppInitialize(&app, "Demos",
  994.         NULL, 0, &argc, argv, NULL, NULL);
  995.  
  996.     label = XmStringCreateSimple(
  997.         "Boy, is *this* going to take a long time.");
  998.     button = XtVaCreateManagedWidget("button",
  999.         xmPushButtonWidgetClass, shell,
  1000.         XmNlabelString,          label,
  1001.         NULL);
  1002.     XmStringFree(label);
  1003.     XtAddCallback(button, XmNactivateCallback, get_busy, argv[1]);
  1004.  
  1005.     XtRealizeWidget(shell);
  1006.     XtAppMainLoop(app);
  1007. }
  1008.  
  1009. void
  1010. get_busy(widget)
  1011. Widget widget;
  1012. {
  1013.     int n;
  1014.  
  1015.     TimeoutCursors(True, True);
  1016.     for (n = 0; n < 10; n++) {
  1017.         sleep(1);
  1018.         if (CheckForInterrupt()) {
  1019.             puts("Interrupt!");
  1020.             break;
  1021.         }
  1022.     }
  1023.     if (n == 10)
  1024.         puts("done.");
  1025.     TimeoutCursors(False, NULL);
  1026. }
  1027.  
  1028. /* The interesting part of the program -- extract and use at will */
  1029. static Boolean stopped;  /* True when user wants to stop processing */
  1030. static Widget dialog;    /* WorkingDialog displayed when timed out */
  1031.  
  1032. /* timeout_cursors() turns on the "watch" cursor over the application
  1033.  * to provide feedback for the user that he's going to be waiting
  1034.  * a while before he can interact with the appliation again.
  1035.  */
  1036. void
  1037. TimeoutCursors(on, interruptable)
  1038. int on, interruptable;
  1039. {
  1040.     static int locked;
  1041.     static Cursor cursor;
  1042.     extern Widget shell;
  1043.     XSetWindowAttributes attrs;
  1044.     Display *dpy = XtDisplay(shell);
  1045.     XEvent event;
  1046.     Arg args[1];
  1047.     XmString str;
  1048.     extern void stop();
  1049.  
  1050.     /* "locked" keeps track if we've already called the function.
  1051.      * This allows recursion and is necessary for most situations.
  1052.      */
  1053.     on? locked++ : locked--;
  1054.     if (locked > 1 || locked == 1 && on == 0)
  1055.         return; /* already locked and we're not unlocking */
  1056.  
  1057.     stopped = False; /* doesn't matter at this point; initialize */
  1058.     if (!cursor) /* make sure the timeout cursor is initialized */
  1059.         cursor = XCreateFontCursor(dpy, XC_watch);
  1060.  
  1061.     /* if "on" is true, then turn on watch cursor, otherwise, return
  1062.      * the shell's cursor to normal.
  1063.      */
  1064.     attrs.cursor = on? cursor : None;
  1065.  
  1066.     /* change the main application shell's cursor to be the timeout
  1067.      * cursor (or to reset it to normal).  If other shells exist in
  1068.      * this application, they will have to be listed here in order
  1069.      * for them to have timeout cursors too.
  1070.      */
  1071.     XChangeWindowAttributes(dpy, XtWindow(shell), CWCursor, &attrs);
  1072.  
  1073.     XFlush(dpy);
  1074.  
  1075.     if (on) {
  1076.         /* we're timing out, put up a WorkingDialog.  If the process
  1077.          * is interruptable, allow a "Stop" button.  Otherwise, remove
  1078.          * all actions so the user can't stop the processing.
  1079.          */
  1080.         str = XmStringCreateSimple("Busy.  Please Wait.");
  1081.         XtSetArg(args[0], XmNmessageString, str);
  1082.         dialog = XmCreateWorkingDialog(shell, "Busy", args, 1);
  1083.         XmStringFree(str);
  1084.         XtUnmanageChild(
  1085.             XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON));
  1086.         if (interruptable) {
  1087.             str = XmStringCreateSimple("Stop");
  1088.             XtVaSetValues(dialog, XmNcancelLabelString, str, NULL);
  1089.             XmStringFree(str);
  1090.             XtAddCallback(dialog, XmNcancelCallback, stop, NULL);
  1091.         } else
  1092.             XtUnmanageChild(
  1093.                 XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
  1094.         XtUnmanageChild(
  1095.             XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
  1096.         XtManageChild(dialog);
  1097.     } else {
  1098.         /* get rid of all button and keyboard events that occured
  1099.          * during the time out.  The user shouldn't have done anything
  1100.          * during this time, so flush for button and keypress events.
  1101.          * KeyRelease events are not discarded because accelerators
  1102.          * require the corresponding release event before normal input
  1103.          * can continue.
  1104.          */
  1105.         while (XCheckMaskEvent(dpy,
  1106.                 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
  1107.                 | PointerMotionMask | KeyPressMask, &event)) {
  1108.             /* do nothing */;
  1109.         }
  1110.         XtDestroyWidget(dialog);
  1111.     }
  1112. }
  1113.  
  1114. /* User Pressed the "Stop" button in dialog. */
  1115. void
  1116. stop(dialog)
  1117. Widget dialog;
  1118. {
  1119.     stopped = True;
  1120. }
  1121.  
  1122. Boolean
  1123. CheckForInterrupt()
  1124. {
  1125.     extern Widget shell;
  1126.     Display *dpy = XtDisplay(shell);
  1127.     Window win = XtWindow(dialog);
  1128.     XEvent event;
  1129.  
  1130.     /* Make sure all our requests get to the server */
  1131.     XFlush(dpy);
  1132.  
  1133.     /* Let motif process all pending exposure events for us. */
  1134.     XmUpdateDisplay(shell);
  1135.  
  1136.     /* Check the event loop for events in the dialog ("Stop"?) */
  1137.     while (XCheckMaskEvent(dpy,
  1138.             ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
  1139.             PointerMotionMask | KeyPressMask | KeyReleaseMask,
  1140.             &event)) {
  1141.         /* got an "interesting" event. */
  1142.         if (event.xany.window == win)
  1143.             XtDispatchEvent(&event); /* it's in our dialog.. */
  1144.         else /* uninteresting event--throw it away and sound bell */
  1145.             XBell(dpy, 50);
  1146.     }
  1147.     return stopped;
  1148. }
  1149.  
  1150.  
  1151. -----------------------------------------------------------------------------
  1152. Subject: 140)  What order should the libraries be linked in?
  1153. [Last modified: August 92]
  1154.  
  1155. Answer: At link time, use the library order  -lXm -lXt -lX11. There are two
  1156. reasons for this (dbrooks@osf.org):
  1157.  
  1158. On most systems, the order matters because the linker won't re-scan a library
  1159. once it is done with it.  Thus any references to Xlib calls from Xm will
  1160. probably be unresolved.
  1161.  
  1162. The [other] problem is that there are two VendorShell widgets. A dummy is
  1163. provided in the Xt library, but a widget set will rely on its own being
  1164. referenced.  If you mention Xt first, the linker will choose the wrong one.
  1165.  
  1166. Motif code will wrongly assume the Motif VendorShell has been class-
  1167. initialized [and will probably crash].
  1168.  Xaw has a similar problem, but a softer landing; it only complains about
  1169. unregistered converters.
  1170.  
  1171.  
  1172. -----------------------------------------------------------------------------
  1173. Subject: 141)  How do I use xmkmf for Motif clients?
  1174.  
  1175. [Last modified: October 1992]
  1176.  
  1177. Answer: This advice comes from dbrooks@osf.org:
  1178.  
  1179. There are a number of intractable problems with using X configuration files
  1180. and xmkmf, while trying to make it easy to build Motif.  Not the least of
  1181. these, but one I've never heard mentioned yet, is that the rules for
  1182. contructing the names of shared library macros are machine-dependent, and in
  1183. the various xxxLib.tmpl files.  Do we edit all those files to add definitions
  1184. for XMLIB, DEPXMLIB, etc., or do we put a maze of #ifdefs into the Motif.tmpl
  1185. file?
  1186.  
  1187. Please note that, if you install Motif, it overwrites your installed
  1188. Imake.tmpl with one that includes Motif.tmpl and Motif.rules.
  1189.  
  1190. With those caveats, I think the following guidelines will help.
  1191.  
  1192. David Brooks OSF
  1193.  
  1194. Clients in the X11R5 release use the xmkmf command to build Makefiles.  In
  1195. general, the xmkmf command cannot be used for Motif clients, because of the
  1196. need to consider the UseInstalledMotif flag separately.  Since xmkmf is a
  1197. simple script that calls imake, it is easy to construct the proper call to
  1198. imake using the following rules.
  1199.  
  1200. In the following, replace {MTOP} by the toplevel directory with the Motif
  1201. source tree, and {XTOP} by the toplevel ("mit") directory with the X source.
  1202. It is assumed that the directory containing your installed imake is in your
  1203. PATH.
  1204.  
  1205. When needed, the imake variables XTop and MTop are normally set in your
  1206. site.def (to {XTOP} amd {MTOP} respectively); however they may also be set
  1207. with additional -D arguments to imake.
  1208.  
  1209. 1. With both X and Motif in their source trees, ensure the imake variables
  1210.    XTop and MTop are set, and use:
  1211.  
  1212.         ${XTOP}/config/imake -I{MTOP}/config
  1213.  
  1214. 2. With Motif in its source tree, and X installed, ensure MTop is set, and
  1215.    use:
  1216.  
  1217.         imake -I{MTOP}/config -DUseInstalled
  1218.  
  1219. 3. With both Motif and X installed, and a nonstandard ProjectRoot (see
  1220.    site.def for an explanation of this), use:
  1221.  
  1222.         imake -DUseInstalled -DUseInstalledMotif -I{ProjectRoot}/lib/X11/config
  1223.  
  1224.    or, if the configuration files are in /usr/lib/X11/config:
  1225.  
  1226.         imake -DUseInstalled -DUseInstalledMotif
  1227.  
  1228.  
  1229. To build a simple Imakefile, remember to include lines like this:
  1230.  
  1231.         LOCAL_LIBRARIES = XmClientLibs
  1232.                 DEPLIBS = XmClientDepLibs
  1233.  
  1234. Or, for a client that uses uil/mrm, replace these by MrmClientLibs and
  1235. MrmClientDepLibs, and also use:
  1236.  
  1237.         MSimpleUilTarget(program)
  1238.  
  1239. to build the client and uid file.  Look at the demos for more examples.
  1240.  
  1241.  
  1242. And Paul Howell <grue@engin.umich.edu> added:
  1243.  
  1244. i did this, calling the new script "xmmkmf".  It passes both -DUseInstalled
  1245. and -DUseInstalledMotif.
  1246.  
  1247. and i modified the stock R5 Imake.tmpl to do this:
  1248.  
  1249. #include <Project.tmpl>
  1250. #ifdef UseInstalledMotif
  1251. #include <Motif.tmpl>
  1252. #endif
  1253.  
  1254. #include <Imake.rules>
  1255. #ifdef UseInstalledMotif
  1256. #include <Motif.rules>
  1257. #endif
  1258.  
  1259. the result was something that does both athena and motif rules.  and it really
  1260. works, just that easy!
  1261.  
  1262.  
  1263. -----------------------------------------------------------------------------
  1264. Subject: 142)  How do I make context sensitive help?  The Motif Style Guide
  1265. says that an application must initiate context-sensitive help by changing the
  1266. shape of the pointer to the question pointer. When the user moves the pointer
  1267. to the component help is wanted on and presses BSelect, any available context
  1268. sensitive help for the component must be presented, and the pointer reverts
  1269. from the question pointer.
  1270. [Last modified: August 92]
  1271.  
  1272. Answer: A widget that gives context sensitive help would place this help in
  1273. the XmNhelpCallback function. To trigger this function: (from Martin G C
  1274. Davies, mgcd@se.alcbel.be)
  1275.  
  1276. I use the following callback that is called when the "On Context" help
  1277. pulldown menu is selected. It does the arrow bit and calls the help callbacks
  1278. for the widget. It also zips up the widget tree looking for help if needs be.
  1279. I don't restrict the arrows motion so I can get help on dialog boxes. No
  1280. prizes for guessing what "popup_message" does.
  1281.  
  1282.  
  1283. static void ContextHelp(
  1284.     Widget              w ,
  1285.     Opaque              * tag ,
  1286.     XmAnyCallbackStruct * callback_struct
  1287. )
  1288. {
  1289.     static Cursor   context_cursor = NULL ;
  1290.     Widget          context_widget ;
  1291.  
  1292.     if ( context_cursor == NULL )
  1293.         context_cursor = XCreateFontCursor( display, XC_question_arrow ) ;
  1294.  
  1295.     context_widget = XmTrackingLocate( top_level_widget,
  1296.                                 context_cursor, FALSE ) ;
  1297.  
  1298.     if ( context_widget != NULL ) /* otherwise its not a widget */
  1299.     {
  1300.         XmAnyCallbackStruct cb ;
  1301.  
  1302.         cb.reason = XmCR_HELP ;
  1303.         cb.event = callback_struct->event ;
  1304.  
  1305.         /*
  1306.          * If there's no help at this widget we'll track back
  1307.            up the hierarchy trying to find some.
  1308.          */
  1309.  
  1310.         do
  1311.         {
  1312.             if ( ( XtHasCallbacks( context_widget, XmNhelpCallback ) ==
  1313.                                                 XtCallbackHasSome ) )
  1314.             {
  1315.                 XtCallCallbacks( context_widget, XmNhelpCallback, & cb ) ;
  1316.                 return ;
  1317.             }
  1318.             else
  1319.                 context_widget = XtParent( context_widget ) ;
  1320.         } while ( context_widget != NULL ) ;
  1321.     }
  1322.  
  1323.     popup_message( "No context-sensitive help found\n\
  1324. for the selected object." ) ;
  1325. }
  1326.  
  1327.  
  1328.  
  1329. Dave Bonnett suggested, to use the following translations for XmText (and
  1330. XmTextField) widgets to get the same help with key strokes, and to provide an
  1331. accelerator label in the Context help menu entry.
  1332.  
  1333. MyApp*XmText*translations: #override\n\
  1334.                                 <Key>F1:    Help()
  1335.  
  1336. MyApp*Help_menu*Contextual Help.acceleratorText:   F1
  1337.  
  1338. MyApp*defaultVirtualBindings:           osfBackSpace : <Key>Delete\n\
  1339.                                         osfRight : <Key>Right\n\
  1340.                                         osfLeft  : <Key>Left\n\
  1341.                                         osfUp    : <Key>Up\n\
  1342.                                         osfHelp  : <Key>F1\n\
  1343.                                         osfDown  : <Key>Down
  1344.  
  1345. -----------------------------------------------------------------------------
  1346. Subject: 143) TOPIC: ACKNOWLEDGEMENTS
  1347.  
  1348. This list was compiled using questions and answers posed to
  1349. comp.windows.x.motif and motif-talk. Some extracts were also taken from FAQs
  1350. of comp.windows.x.  To all who contributed one way or the other, thanks! I
  1351. haven't often given individual references, but  you may recognise
  1352. contributions. If I have mangled them too much, let me know.
  1353.  
  1354.  
  1355.  
  1356. That's all folks!
  1357.  
  1358.  
  1359. +----------------------+---+
  1360.   Jan Newmarch, Information Science and Engineering,
  1361.   University of Canberra, PO Box 1, Belconnen, Act 2616
  1362.   Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999
  1363.  
  1364.   ACSnet: jan@ise.canberra.edu.au
  1365.   ARPA:   jan%ise.canberra.edu.au@uunet.uu.net
  1366.   UUCP:   {uunet,ukc}!munnari!ise.canberra.edu.au!jan
  1367.   JANET:  jan%au.edu.canberra.ise@EAN-RELAY
  1368.  
  1369. +--------------------------+
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854. Local Variables:
  1855. mode: outline
  1856. outline-regexp: "Subject: +[0-9]+)"
  1857. eval: (hide-body)
  1858. End:
  1859. --
  1860. +----------------------+---+
  1861.   Jan Newmarch, Information Science and Engineering,
  1862.   University of Canberra, PO Box 1, Belconnen, Act 2616
  1863.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  1864.